<?php
/**
 * Created by JetBrains PhpStorm.
 * User: akrug
 * Date: 29.05.12
 * Time: 13:33
 * To change this template use File | Settings | File Templates.
 */
class Backend_Form_User_Password extends UcsMvc_AbstractForm
{
    public $elementDecorators = array('ViewHelper', 'Errors','Label');

    public function init() {
        $element = new Zend_Form_Element_Password('password');
        $element
            ->setRequired(true)
            ->setLabel($this->_translator->translate('Neues Passwort', $this->_language))
            ->addValidator('NotEmpty', true, array('messages'=>'Bitte geben Sie ein Passwort ein.'))
            ->addValidator('stringLength', true, 8)
            ->addValidator('Regex',true, array('pattern' => "/^[A-Za-z0-9[:punct:]]{8,}$/"))
            ->addValidator('Regex',true, array('pattern' => "/[0-9]+/"))
            ->addValidator('Regex',true, array('pattern' => "/[A-Za-z]+/"))
            ->addValidator('Regex',true, array('pattern' => "/[[:punct:]]+/"))
            ->addErrorMessage($this->_translator->translate('passwordInvalid', $this->_language));
        $this->addElement($element);

        $element = new Zend_Form_Element_Password('passwordConfirm');
        $element
            ->setRequired ( true )
            ->setLabel($this->_translator->translate('Passwort bestätigen', $this->_language))
            ->addValidator('NotEmpty', true, array('messages'=>'Bitte geben Sie ein Passwort ein.'))
            ->addValidator('identical', true, array('token' => 'password'))
            ->addErrorMessage($this->_translator->translate('passwordConfirmInvalid', $this->_language));
        $this->addElement($element);

        $this->prepareDecorators();
    }
}
